package com.dwsoft.controller;

import com.dwsoft.service.IWordService;
import com.dwsoft.utils.XStreamUtil;
import com.dwsoft.xml.XDocument;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author sqw
 * @version 1.0
 * @description TODO
 * @ClassName TestController
 * @Date 2020/8/6
 * @since jdk1.8
 */
@RestController
public class TestController {

    @Resource
    private IWordService wordService;

    @RequestMapping("/test")
    public String test(String id){
        try {
            return wordService.generateWord(id,null);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "失败";
    }

    @RequestMapping("/xml")
    public void xml(){
        String xml="<document>\n" +
                "    <paragraph type=\"heading1\">\n" +
                "        <piece>一级标题</piece>\n" +
                "    </paragraph>\n" +
                "    <paragraph type=\"heading2\">\n" +
                "        <piece>二级标题</piece>\n" +
                "    </paragraph>\n" +
                "    <paragraph type=\"heading3\">\n" +
                "        <piece>三级标题</piece>\n" +
                "    </paragraph>\n" +
                "    <paragraph type=\"paragraphPiece\">\n" +
                "        <piece>文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本</piece>\n" +
                "    </paragraph>\n" +
                "</document>";
        //XmlNode rootNode = (XmlNode) XStreamUtil.xmlToBean(xml);

        XDocument rootNode = (XDocument) XStreamUtil.xmlToBean(xml);
        System.out.println("");
    }
}
